package common.proxy;

import java.lang.reflect.Proxy;

/**
 * Created by dong peng on 2017/11/30.
 *
 * 代理测试类
 */
public class ProxyTest {

    public static void main(String[] args) {

        // 将被代理的目标类
        TargetInterface targetInterface = new TargetImpl();

        // 动态代理生成对象
        TargetInterface proxyInstance = (TargetInterface) Proxy.newProxyInstance(ProxyTest.class.getClassLoader(),
                new Class[]{TargetInterface.class}, new MyProxyHandler(targetInterface));

        proxyInstance.print("哈哈");
    }
}
